import 'dart:convert';

import 'package:flutter/cupertino.dart';

class Tags extends StatelessWidget {
  final List tags;
  final String type;
  final Map border;
  final double fontSize;
  final List<double> padding;
  final int bgColor;
  final int fontColor;
  final Map<String, double> margin;
  Tags(
      {this.tags = const [],
      this.type = "ghost",
      this.border = const {"color": 0xff000000, "width": 1.0, "radius": 1.0},
      this.fontSize = 10,
      this.padding = const [10.0, 5.0, 10.0, 5.0],
      this.bgColor = 0xffffffff,
      this.fontColor = 0xff000000,
      this.margin = const {
        "left": 0.0,
        "top": 0.0,
        "right": 0.0,
        "bottom": 0.0,
      }});

  List<Widget> getTags(list) {
    List<Widget> tags = [];
    final int _bgColor = type == 'ghost' ? 0 : bgColor;

    for (int i = 0; i < list.length; i++) {
      tags.add(Container(
          decoration: BoxDecoration(
              color: Color(_bgColor),
              border: Border.all(
                  color: Color(border["color"]), width: border["width"]),
              borderRadius:
                  BorderRadius.all(Radius.circular(border["radius"]))),
          padding: EdgeInsets.fromLTRB(
              padding[0], padding[1], padding[2], padding[3]),
          child: new Text(list[i],
              style:
                  new TextStyle(fontSize: fontSize, color: Color(fontColor))),
          margin: EdgeInsets.only(right: margin["right"])));
    }
    return tags;
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: getTags(tags),
    );
  }
}
